<template>

  <div>
    <el-form ref="searchForm" :inline="true" :model="searchForm" class="demo-form-inline">
      <el-form-item label="收房合同编号">
        <el-input v-model="searchForm.sfContractNo" placeholder="收房合同编号" />
      </el-form-item>
      <el-form-item label="业主姓名">
        <el-input v-model="searchForm.ownerName" placeholder="业主姓名" />
      </el-form-item>
      <el-form-item label="小区名称">
        <el-input v-model="searchForm.premiseName" placeholder="小区名称" />
      </el-form-item>
      <el-form-item label="合同录入日期">
        <el-date-picker
          v-model="times"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          @change="handleTime"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSearch()">查询</el-button>
        <el-button @click="resetForm()">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table
      :data="tableData"
      stripe
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        type="selection"
        width="55"
      />
      <el-table-column prop="sfContractNo" label="合同编号" width="180" />
      <el-table-column prop="premiseName" label="小区" width="180" />

      <el-table-column prop="signUserMobile" label="电话" width="180" />
      <el-table-column prop="leaseStartTime" label="起租日期" width="180" />
      <el-table-column prop="leaseEndTime" label="结束日期" width="180" />
      <el-table-column prop="conInfoTime" label="录入日期" width="180" />
      <el-table-column prop="conAudTime" label="审核日期" width="180" />
      <el-table-column prop="ownerName" label="业主" width="180" />
      <el-table-column prop="userName" label="操作人" width="180" />
      <el-table-column
        fixed="right"
        label="操作"
        width="100"
      >
        <template>
          <el-upload
            class="upload-demo"
            action="http://localhost:9999/house-resource/oss/upload"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :file-list="fileList"
          >
            <el-button size="small" type="primary">导入还款计划</el-button>
          </el-upload>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :current-page="current"
      :page-sizes="[10,20,30]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      fileList: [],
      times: [],
      tableData: [],
      size: 10,
      current: 1,
      total: 0,
      multipleSelection: [],
      searchForm: {},
      title: '',
      deptDialogVisible: false
    }
  },
  created() {
    this.initData()
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file+'--------------------');
    },
    handleTime(val){
        console.log(val+')_________-')
        if (val){
          this.times = val
          this.searchForm.inputDateStart = this.times[0]
          this.searchForm.inputDateEnd = this.times[1]
        }
    },
    resetForm() {
      this.times=[]
      this.searchForm={}
    },
    initData() {
      this.axios({
        method: 'post',
        url: 'http://localhost:9999/house-foreclosure/tSfContract/searchContractList',
        params: {
          pageNum: this.current,
          pageSize: this.size,
          sfContractNo: this.searchForm.sfContractNo,
          ownerName: this.searchForm.ownerName,
          premiseName: this.searchForm.premiseName,
          inputDateStart: this.searchForm.inputDateStart,
          inputDateEnd: this.searchForm.inputDateEnd
        }
      }).then((res) => {
        if (res.data.obj.list) {
          this.tableData = res.data.obj.list
          this.total = res.data.obj.total
        }
      })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.size = val
      this.initData()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.current = val
      this.initData()
    },
    handleSearch(){
      this.current=1;
      this.initData()
    },
  }
}
</script>

<style scoped>

</style>

}
